package org.openrbac.rbac.controller;

import org.openrbac.rbac.controller.base.BaseController;
import org.openrbac.rbac.entity.Order;
import org.openrbac.rbac.entity.Product;
import org.openrbac.rbac.service.OrderService;
import org.openrbac.rbac.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author 梁富贵
 * @Date 2024/6/5
 **/
@RestController
@RequestMapping("/product")
public class ProductController extends BaseController<ProductService, Product> {
    @Autowired
    private OrderService orderService;

    @GetMapping("/getProduct")
    public Product plus(@RequestParam("name") String name) {
        return service.getSalePageProducts(name);
    }

    @PostMapping("/buyGoods")
    public Boolean buyGoods(@RequestBody Order order) {
        return orderService.addOrder(order);
    }

    @PostMapping("/addToCart")
    public Boolean addToCart(@RequestBody Order order) {
        return false;
    }

}
